package com.d0323;

public class Course2 {
    String title;
    int price;

    public Course2(String title, int price) {
        this.title = title;
        this.price = price;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Course2 course2 = (Course2) o;

        if (price != course2.price) return false;
        return title != null ? title.equals(course2.title) : course2.title == null;
    }

    @Override
    public int hashCode() {
        int result = title != null ? title.hashCode() : 0;
        result = 31 * result + price;
        return result;
    }

    public static void main(String[] args) {
        Course c1 = new Course("math",100);
        Course c2 = new Course("math",100);
        System.out.println(c1==c2);
        System.out.println(c1.equals(c2));
    }
}
